<?php require_once("db_connect.php"); ?>
<html>
<head>
<style>
table {
	text-align:center;
	font-family:arial;
}
table, th, td { border:1px solid grey; }
th { background:lightgrey; }
th, td { padding:1em; }
.odd { background-color:lightblue; }
.even { background-color:deepskyblue; }
</style>
</head>
<body>
<?php
define("TABLE", "people");
$str = "SELECT FIRST_NAME, LAST_NAME FROM ".TABLE;
$str = $db->real_escape_string($str);

// print all names in a table
$result = $db->query($str);

echo <<<EOF
<table>
<th>First Name</th>
<th>Last Name</th>
EOF;
while($row = $result->fetch_assoc()) {
	$tr = "<tr><td>".$row["FIRST_NAME"]."</td><td>".$row["LAST_NAME"]."</td></tr>";
	echo $tr;
}
echo "</table><br><br>";


// print all names in FORMATTED table
$result = $db->query($str);

echo <<<EOF
<table>
<th>First Name</th>
<th>Last Name</th>
EOF;

// check for odd, even, give variable class
$i = 0;
while($row = $result->fetch_assoc()) {
	$i++;
	if ( $i%2 == 0 ) {
		$tr = "<tr class='even'>";
	} else {
		$tr = "<tr class='odd'>";
	}
	$tr = $tr . "<td>".$row["FIRST_NAME"]."</td><td>".$row["LAST_NAME"]."</td></tr>";
	echo $tr;
}
echo "</table><br><br>";


?>
</body>
</html>